package com.youlai.boot.util;

import cn.hutool.core.util.StrUtil;

import java.util.HashMap;
import java.util.Map;

public class MapUtils {
    public static Map<String, String> getFeatureMap(String template) {
        Map<String, String> ruleMap = new HashMap<>();
        if (StrUtil.isBlank(template)) {
            return ruleMap;
        }
        if (!template.contains(";")) {
            return ruleMap;
        }
        String[] split = template.split(";");
        for (String s : split) {
            if (s.contains(":")) {
                String[] result = s.split(":");
                if (result.length == 2) {
                    String key = result[0].trim();   // 使用 trim() 去除前后空格
                    String value = result[1].trim();
                    ruleMap.put(key, value);
                }
            }
        }
        return ruleMap;
    }
}
